home *** CD-ROM | disk | FTP | other *** search
/ BMUG PD-ROM B4 / PD-ROM B4.iso / Entertainment / Strategy / Robots / bot 1.0.1 / Tutorial / BASIC / Corner < prev    next >
Encoding:
Text File  |  1991-06-23  |  1.3 KB  |  58 lines  |  [TEXT/?bDv]

  1. !
  2. ! Corner
  3. !
  4. ! This bot is just like Finder, except that it first moves into
  5. ! the upper-left (0,0) corner of the arena.  This way, it only
  6. ! needs to scan a 90 degree arc to cover the whole arena.
  7. !
  8.  
  9. #DATA
  10.  
  11. EQU INCR 7
  12.  
  13. DEF s
  14. DEF tempScan
  15.  
  16. #CODE BASIC
  17.  
  18. :XMoveToCorner
  19.     Velocity -$XLOC, 0      ! Velocity equals negative position
  20.     If ($XLOC > 10) Then
  21.         Goto XMoveToCorner
  22. :YMoveToCorner
  23.     Velocity 0, -$YLOC      ! Velocity equals negative position
  24.     If ($YLOC > 10) Then
  25.         Goto YMoveToCorner
  26.     Velocity 0, 0           ! (ELSE) stop
  27.     
  28. ! This bot uses a FOR-NEXT loop to make a given scan pass.  It
  29. ! only scans up to 93 degrees so that it doesn't waste time
  30. ! scanning the arena wall.
  31.  
  32. :ScanLoop
  33.     For s = Random(INCR)-3 To 93 Step INCR
  34.         SCAN ANGLE S
  35.         If ($FOUND <> 0) Then Gosub LockWeapon
  36.       Next S
  37.     
  38.     Goto ScanLoop
  39.  
  40.  
  41. ! This is a subroutine to fire at a located enemy bot.  The
  42. ! scanner information about the bot is presumed to be in the S
  43. ! registers.
  44.  
  45. :LockWeapon
  46.     Fire Weapon 1, Angle $ANGLE
  47.     tempScan = $ANGLE
  48.     Scan Angle tempScan
  49.     If ($FOUND <> 0) Then Goto LockWeapon
  50.     
  51.     Scan Angle tempScan-20          ! Try to find the bot again
  52.     If ($FOUND <> 0) Then Goto LockWeapon
  53.     Scan Angle tempScan-10
  54.     If ($FOUND <> 0) Then Goto LockWeapon
  55.   Return                            ! Couldn't find it.
  56.  
  57. #END
  58.